<?php
class Imageupload_Model_Imageactiondecision implements Imageupload_Model_Mainable{
    
    private $action_handler;
    private $core_controller_csrftoken;
    
    public function main(array $variables = null) {
        switch($variables['get']['page']){
            case "dodaj":
                return $this->add_photo($variables);
                break;
            case "wstaw":
                return $this->upload_photo($variables);
                break;
            default:
                return $this->default_action($variables);
                break;
        }
    }
    
    private function upload_photo(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_handler = new Imageupload_Model_Insertimage;
        return $this->action_handler->main($variables);
    }
    
    private function add_photo(array $variables = null){
        $page['template'] = WEB_ROOT_FOLDER."imageupload/views/add.php";
        $page['csrf_token'] = $this->other_data($variables);
        return $page;
    }
    
    private function default_action(array $variables = null){
        unset($variables);
        $this->action_handler = new Imageupload_Model_Imageupload;
        return $this->action_handler->main($variables);
    }
    
    private function other_data(array $variables = null){
        $this->action_handler = new Core_Controller_Csrftoken;
        return $this->action_handler->main($variables);
    }

}
